package PacMan;

/**
 * Coordinates are [X, Y].
 * Origin is top-left of screen.
 */
public class World {
	// True if this tile is navigable.
	// i.e., if it is a wall it is false.
	public boolean[][] tiles;
	public int width;
	public int height;
	public boolean dead = false;
	
	// [ghost#][x,y]
	public int[][] ghostLocations;
	
	public World(int width, int height) {
		tiles = new boolean[width][height];
		ghostLocations = new int[4][2];
		this.width = width;
		this.height = height;
	}
	
	public static World buildMap(GameModel gm) {
		World newWorld = new World(28,31);
		for (int x = 0; x < 28; x++) {
			for (int y = 0; y < 31; y++) {
				if ((gm.m_gameState[x][y] & GameModel.GS_FOOD) != 0 ||
						(gm.m_gameState[x][y] & GameModel.GS_POWERUP) != 0) {
					newWorld.tiles[x][y] = true;
				}
			}
		}
		return newWorld;
	}
	
	public String toString() {
		String temp = "";
		for (int y = 0; y < this.height; y++) {
			for (int x = 0; x < this.width; x++) {
				if (this.tiles[x][y]) {
					temp += "O";
				} else {
					temp += "X";
				}
			}
			temp += '\n';
		}
		return temp;
	}
}
